package com.atguigu.spzx.service.handler;

import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.service.exception.GuliException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ClassName: GlobalExceptionHandler
 * Package: com.atguigu.spzx.service.handler
 * Description:
 *
 * @Author 刘强
 * @Create 2024/6/29 13:09
 * @Version 1.0
 */
@RestControllerAdvice
public class GlobalExceptionHandler  {

    @ExceptionHandler(RuntimeException.class)
    public Result error(RuntimeException e) {
        e.printStackTrace();
        return Result.build(null, 201, e.getMessage());
    }

    @ExceptionHandler(GuliException.class)
    public Result error(GuliException e) {
        e.printStackTrace();
        return Result.build(null,e.getCode(),e.getMessage());
    }

}
